<?php

class Application_Model_DbTable_Messages extends Zend_Db_Table_Abstract
{

    protected $_name = 'Messages';

	public function createMessage($title, $text)
 	{
 		$time = new Zend_Date();
    	$time1=$time->toString('YYYY-MM-dd HH:mm:ss');
  		
    	$data = array(
	   		'Title' => $title,
	   		'Text' => $text,
	   		'DateSent' => $time1,
  		);
  		return $this->insert($data);	//se dodava stavka vo bazata i se vrakja id na istata.		
 	}

 	public function getMessage($id)
    {
     	$id = (int)$id;
  		$row = $this->fetchRow('id = ' . $id);         
  		if (!$row) {
   			throw new Exception("Could not find any row for message with id $id");
  		}
  		return $row->toArray();
    }
}

